import { configureStore } from '@reduxjs/toolkit'
import { combineReducers } from 'redux'
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";

import userReducer from './userSlice'

const persistConfig = {
    key: "persist",
    storage,
};
const reducers = combineReducers({
    user: userReducer,
});
const persistedReducer = persistReducer(persistConfig, reducers);

const store = configureStore({
    reducer: persistedReducer,
    middleware: getDefaultMiddleware => getDefaultMiddleware({  //解决动作无法序列化的问题
        //关闭redux序列化检测
        serializableCheck: false
    })
})

export const persistor = persistStore(store);

export default store;